<?php
/**
 * 定制
 *
 * @copyright  Copyright (c) 2015-2025 NcPHP Inc. (http://www.ncphp.com)
 * @license    http://www.ncphp.com/
 * @link       http://www.ncphp.com/
 * @author	   NcPHP Team
 * @since      File available since Release v2.1
 */
defined('InNcPHP') or exit('Access Invalid!');

class customizeControl extends SystemControl{
	private $links = array(
		array('url'=>'act=customize&op=index','lang'=>'nc_manage')
	);

	public function __construct(){
		parent::__construct();
		Language::read('customize');
	}

	/**
	 * 列表
	 */
	public function indexOp(){
	    /* @var customizeModel $model */
        $model = Model('customize');

        //查询条件
        $condition = array();
        if (isset($_GET['search_com']) && $_GET['search_com']) {
            $condition['company|username'] = array('like','%'.$_GET['search_com'].'%');
        }
        $time_from = strtotime($_GET['search_stime']);
        $time_to = strtotime($_GET['search_etime']);
        if ($time_from && $time_to) {
            $condition['addtime'] = array('between',array($time_from,$time_to));
        } elseif ($time_from) {
            $condition['addtime'] = array('egt',$time_from);
        } elseif ($time_to) {
            $condition['addtime'] = array('elt',$time_to);
        }
        if (isset($_GET['search_type']) && is_numeric($_GET['search_type'])) {
            $condition['type'] = intval($_GET['search_type']);
        }
        if (isset($_GET['search_status']) && is_numeric($_GET['search_status'])) {
            $condition['status'] = intval($_GET['search_status']);
        }

        $lists = $model->getCustomizeListPage($condition);
        Tpl::output('lists', $lists);

        Tpl::output('types', $model->type);
        Tpl::output('status', $model->status);
        Tpl::output('search', $_GET);
        Tpl::output('page', $model->showpage());

        Tpl::output('top_link',$this->sublink($this->links,'index'));
        Tpl::showpage('customize.index');
	}

    /**
     * 查询
     */
	public function getOp()
    {
        /* @var customizeModel $model */
        $model = Model('customize');
        $info = $model->getCustomizeInfo(array('id'=>intval($_GET['id'])));
        output_data($info);
    }

    /**
     * 处理
     */
	public function handleOp()
    {
        /* @var customizeModel $model */
        $model = Model('customize');

        $id = intval($_POST['id']);
        $params = array(
            'status' => 1,
            'deal_status' => intval($_POST['deal_status']),
            'deal_who' => $_POST['deal_who'],
            'deal_remark' => $_POST['deal_remark'],
        );
        $res = $model->updateCustomize(array('id'=>$id), $params);
        output_data($res);
    }
}
